package view.GUI.graphic;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Stroke;
import java.io.Serializable;

public class Grid implements Serializable {

    int winWidth = 1000;
    int winHeight = 1000;
    boolean grid = true;
    boolean snap = true;
    int gridSizeX = 25;
    int gridSizeY = 25;

    Grid(){}

    public void setDimension(int x, int y) {
        this.winWidth = x;
        this.winHeight = y;
    }

    public void paint(Graphics2D g) {
        Color oldColor = g.getColor();
        Stroke oldStroke = g.getStroke();
        if (grid) {
            g.setColor(Color.BLACK);
            for (int i = gridSizeX; i < winWidth; i = i + gridSizeX) {
                for (int j = gridSizeY; j < winHeight; j = j + gridSizeY) {
                    g.fillOval(i, j, 2, 2);
                }
            }
        }
        g.setStroke(oldStroke);
        g.setColor(oldColor);
    }
}
